Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

readline

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

readline

Simple streaming readline module.

  • 1.3.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2.2M
decreased by-4.5%
Maintainers
1
Weekly downloads
 
Created

What is readline?

The readline npm package is a core Node.js module that provides an interface for reading data from a Readable stream (like process.stdin) one line at a time. It is particularly useful for creating command-line interfaces and reading large files line by line.

What are readline's main functionalities?

Reading Input from stdin

This code sets up a readline interface to read user input from the standard input (stdin). It asks the user 'What is your name?' and prints a greeting with the user's input.

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});
rl.question('What is your name? ', (answer) => {
  console.log(`Hello, ${answer}!`);
  rl.close();
});

Reading a File Line by Line

This example demonstrates how to use readline to read a file line by line. It creates a readline interface with a file stream as input and logs each line to the console as it is read.

const fs = require('fs');
const readline = require('readline');
const rl = readline.createInterface({
  input: fs.createReadStream('file.txt'),
  output: process.stdout,
  terminal: false
});
rl.on('line', (line) => {
  console.log(line);
});

Other packages similar to readline

Keywords

FAQs

Package last updated on 28 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc